home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / copydir.bat < prev    next >
DOS Batch File  |  1994-07-01  |  1KB  |  52 lines

  1. @echo off
  2. !  copydir.bat    Batch file to copy a folder to another folder
  3. !
  4. !  copydir name [dest]
  5. !
  6. !  where 'name' is the folder to be copied and 'dest' is the folder which
  7. !  shall contain a copy of 'name'. Both names can be preceded by paths and
  8. !  volume IDs.
  9. !  If 'dest' is missing, the current directory is used as destination.
  10. !
  11. !  copydir.bat calls extractName
  12. !
  13. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  14. !
  15.  
  16.     ! ensure that the first parameter is there and that the third one is not
  17.     set doserr=13
  18.     if not "%3 " == " " goto ERR_LBL
  19.     if "%1 " == " " goto ERR_LBL
  20.  
  21.     ! ensure that the folder to be copied is there
  22.     set doserr=27
  23.     if not existdir "%1" goto ERR_LBL
  24.  
  25.     ! determine the destination folder
  26.     set copydir_folder=%WHERE%
  27.     if "%2 " == " " goto FOLDER_OK_LBL
  28.     if not existdir "%2" goto ERR_LBL
  29.     set copydir_folder=%2
  30. :FOLDER_OK_LBL
  31.  
  32.     ! get the name of the source folder and make a directory with the same name
  33.     ! in the destination folder
  34.     onerror ERR_LBL
  35.     call extractName "%1" copydir_name
  36.     if not %doserr% == 0 goto ERR_LBL
  37.     if existdir "%copydir_folder%\%copydir_name%" goto DIR_THERE_LBL
  38.     mkdir "%copydir_folder%\%copydir_name%"
  39. :DIR_THERE_LBL
  40.  
  41.     ! do the copying
  42.     xcopy/e "%1" "%copydir_folder%\%copydir_name%"
  43.     goto DONE_LBL
  44.  
  45. :ERR_LBL
  46.     show %doserr%
  47.  
  48. :DONE_LBL
  49.     ! remove the global variables
  50.     set copydir_name=
  51.     set copydir_folder=
  52.